#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QButtonGroup>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
    , vs(3)
{
    ui->setupUi(this);
    QButtonGroup* qbg1 = new QButtonGroup(this);
    qbg1->addButton(ui->rbt_1);
    qbg1->addButton(ui->rbt_2);
    qbg1->addButton(ui->rbt_3);

    QButtonGroup* qbg2 = new QButtonGroup(this);
    qbg2->addButton(ui->rbt_t1);
    qbg2->addButton(ui->rbt_t2);
    qbg2->addButton(ui->rbt_t3);
    qbg2->addButton(ui->rbt_t4);

    QButtonGroup* qbga = new QButtonGroup(this);
    qbga->addButton(ui->rbt_a1);
    qbga->addButton(ui->rbt_a2);
    qbga->addButton(ui->rbt_a3);

    QButtonGroup* qbgb = new QButtonGroup(this);
    qbgb->addButton(ui->rbt_b1);
    qbgb->addButton(ui->rbt_b2);
    qbgb->addButton(ui->rbt_b3);

    QButtonGroup* qbgc = new QButtonGroup(this);
    qbgc->addButton(ui->rbt_c1);
    qbgc->addButton(ui->rbt_c2);
    qbgc->addButton(ui->rbt_c3);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_rbt_1_clicked()
{
    ui->label->setText("当前选中1");
}

void Widget::on_rbt_2_clicked()
{
    ui->label->setText("当前选中2");
}

void Widget::on_rbt_3_clicked()
{
    ui->label->setText("当前选中3");
}

void Widget::on_rbt_t1_clicked(bool checked)
{
    qDebug() << "1 checked|"<<checked;
}

void Widget::on_rbt_t2_pressed()
{
    qDebug() << "2pressed";
}

void Widget::on_rbt_t3_released()
{
    qDebug() << "3released";
}

void Widget::on_rbt_t4_toggled(bool checked)
{
    qDebug() << "4 toggled|"<<checked;
}

//实现选中加入列表 未选中删除列表
void Widget::on_rbt_a1_toggled(bool checked)
{
    if(checked) vs[0] = "汉堡";
    else vs[0] = "";
}

void Widget::on_rbt_a2_toggled(bool checked)
{
    if(checked) vs[0] = "鸡肉卷";
    else vs[0] = "";
}

void Widget::on_rbt_a3_toggled(bool checked)
{
    if(checked) vs[0] = "热狗面包";
    else vs[0] = "";
}

void Widget::on_rbt_b1_toggled(bool checked)
{
    if(checked) vs[1] = "骨肉相连";
    else vs[1] = "";
}

void Widget::on_rbt_b2_toggled(bool checked)
{
    if(checked) vs[1] = "薯条";
    else vs[1] = "";
}

void Widget::on_rbt_b3_toggled(bool checked)
{
    if(checked) vs[1] = "上校鸡块";
    else vs[1] = "";
}

void Widget::on_rbt_c1_toggled(bool checked)
{
    if(checked) vs[2] = "可乐";
    else vs[2] = "";
}

void Widget::on_rbt_c2_toggled(bool checked)
{
    if(checked) vs[2] = "雪碧";
    else vs[2] = "";
}

void Widget::on_rbt_c3_toggled(bool checked)
{
    if(checked) vs[2] = "美年达";
    else vs[2] = "";
}

void Widget::on_pushButton_clicked()
{
    QString s;
    if(vs[0].size())
    {
        s += vs[0];
        if(vs[1].size() || vs[2].size()) s += ',';
    }
    if(vs[1].size())
    {
        s += vs[1];
        if(vs[2].size()) s += ',';
    }
    if(vs[2].size()) s += vs[2];
    ui->label_5->setText("点餐列表：" + s);
}
